﻿using System;
using System.Collections.Generic;
using System.Text;
using Abp.Application.Services;
using KelonProud.Administration.Managers.Application;
using KelonProud.Configuration;
using KelonProud.Configuration.Ui;

namespace KelonProud.Administration.Services
{
    public  interface  IKelonProudSettingAppService : IApplicationService
    {
        void ChangeUserSetting(string key, string value);

        void ChangeUiThemeSetting(string value);

        string GetThemeUiSettingValue();
    }

    public class KelonProudSettingAppService : IKelonProudSettingAppService
    {
        private readonly KelonSettingManager _kelonSettingManager;

        public KelonProudSettingAppService(KelonSettingManager kelonSettingManager)
        {
            _kelonSettingManager = kelonSettingManager;
        }

        public void ChangeUserSetting(string key, string value)
        {
            _kelonSettingManager.SaveSetting(key, value);
        }

        public void ChangeUiThemeSetting(string value)
        {
            ChangeUserSetting(AppSettingNames.UiTheme, value);
        }

        public string GetThemeUiSettingValue()
        {
            var setting = _kelonSettingManager.GetSetting(AppSettingNames.UiTheme);
            return setting != null ? setting.Value : UiThemes.Default.Name;
        }
    }
}
